<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/common/wechatLibs.jsp"%>
<!doctype html>
<html>
<head>
    <title>个人资料</title>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">

		<script src="${ctx}/static/newDate/js/mobiscroll.core-2.5.2.js" type="text/javascript"></script>
		<script src="${ctx}/static/newDate/js/mobiscroll.core-2.5.2-zh.js" type="text/javascript"></script>

		<link href="${ctx}/static/newDate/css/mobiscroll.core-2.5.2.css" rel="stylesheet" type="text/css" />
		<link href="${ctx}/static/newDate/css/mobiscroll.animation-2.5.2.css" rel="stylesheet" type="text/css" />
		<script src="${ctx}/static/newDate/js/mobiscroll.datetime-2.5.1.js" type="text/javascript"></script>
		<script src="${ctx}/static/newDate/js/mobiscroll.datetime-2.5.1-zh.js" type="text/javascript"></script>

		<!-- S 可根据自己喜好引入样式风格文件 -->
		<script src="${ctx}/static/newDate/js/mobiscroll.android-ics-2.5.2.js" type="text/javascript"></script>
		<link href="${ctx}/static/newDate/css/mobiscroll.android-ics-2.5.2.css" rel="stylesheet" type="text/css" />
  
</head>
  <style>
         body{
            background:url(${ctx}/static/wechat/images/my-coin-bg.jpg) 0 2.346667rem no-repeat #f5b24f;background-size:cover;
        }
    </style>
<body>
    <div class="my-base-intro">
        <div class="my-avatar">
            <img id="userImg" src="${ctx}${customUserPO.photo}">
            <i class="arrow-t"></i>
            <span>${customUserPO.nikename}</span>
        </div>
        <div class="my-base-intro-cot">

            <ul>
                <li>
                    <label>手机号</label>
                     <input type="text" value="${customUserPO.mobile}" readonly unselectable="on">
                     <input type="hidden" id="born_date_str"  />
                </li>
                <li>
                    <label>账号</label>
                    <input type="text" id="nikename" value="${customUserPO.username}">
                </li>
                <li>
                    <label>生日</label>
                    <input type="text" id="born_date" value="<fmt:formatDate value="${customUserPO.born_date}" pattern="yyyy-MM-dd"/>" onchange="addAstro()">
                </li>
                <li>
                    <label>性别</label>
                     <select id="sex">
                        <option value="女" <c:if test="${customUserPO.sex=='女'}"> selected</c:if>>女</option>
                        <option value="男"  <c:if test="${customUserPO.sex=='男'}"> selected</c:if>>男</option>
                        <option value="保密" <c:if test="${customUserPO.sex=='保密'}"> selected</c:if>>保密</option>
                    </select>
                </li>
            </ul>
             
            <div class="btn">
                <a href="#" onclick="updateMyInfo();">修改完成</a>
            </div>
        </div>
    </div>
</body>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
var toast = new auiToast();
$(function(){
	 $.ajax({
			type : 'get',
			url : '/weichat/bag/getWechatConfig',
			dataType : 'json',
			success : function(data) {
				
				if (data.appcode == "1") {
					wx.config({
						debug : false,
						appId : data.appid,
						timestamp : data.timestamp,
						nonceStr : data.nonceStr,
						signature : data.signature,
						jsApiList : [ 'chooseImage','previewImage','uploadImage','downloadImage', ]//分享到朋友圈 
					});
				} else { //微信注入权限接口
					

				}
			},
			error : function() {

				toast.fail({
					title : "获取微信签名网络异常",
					duration : 2000
				});

			}
		})
	var currYear = (new Date()).getFullYear();
	var opt = {};
	opt.date = {
		preset: 'date'
	};
	//opt.datetime = { preset : 'datetime', minDate: new Date(2012,3,10,9,22), maxDate: new Date(2014,7,30,15,44), stepMinute: 5  };
	opt.datetime = {
		preset: 'datetime'
	};
	opt.time = {
		preset: 'time'
	};
	opt.default = {
		theme: 'android-ics light', //皮肤样式
		display: 'modal', //显示方式 
		mode: 'scroller', //日期选择模式
		lang: 'zh'
		
	};   
	$("#born_date").scroller('destroy').scroller($.extend(opt['date'], opt['default']));
	var optDateTime = $.extend(opt['datetime'], opt['default']);
   
	 addAstro();
	
})
function getWxConfig() {
		
	}

function updateMyInfo(){
	
	var nikename=$("#nikename").val();
	var born_date=$("#born_date_str").val();
	var sex=$('#sex option:selected') .val();//选中的值
	toast.loading({
        title:"数据处理中"
    })
  
	$.ajax({
		type : 'post',
		url : '${ctx}/weichat/home/updateMyInfo',
		data : {
			custom_user_id:'${customUserPO.custom_user_id}',
			username:nikename,
			born_date:born_date,
			sex:sex
		},
		dataType : 'json',
		success : function(data) {
			if (data) {
				if (data.appcode == "1") {
					toast.success({
					    title:data.appmsg, 
					    duration:2000
					});
					window.location.href ='${ctx}/weichat/home/';
				} else {
					toast.fail({
						title : data.appmsg,
						duration : 2000
					});
				}
			} else {
				toast.fail({
					title : "个人资料修改失败，系统处理异常",
					duration : 2000
				});
			}
		},
		error : function() {
			toast.fail({
				title : "网络异常",
				duration : 2000
			});
		}
	})
	toast.hide();
}
/* function getAstro(month,day){    
    var s="魔羯水瓶双鱼牡羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
    var arr=[20,19,21,21,21,22,23,23,23,23,22,22];
    return s.substr(month*2-(day<arr[month-1]?2:0),2);
}  */
/*  //添加星座
function addAstro(){
	var born_date=$("#born_date").val();
	
	$("#born_date_str").val(born_date);
	if(born_date!=''){
		var array=born_date.split("-"); //字符分割 
		var month=parseInt(array[1]);
		var day=parseInt(array[2]);
		var astro=getAstro(month, day)+'座';
		$("#born_date").val(born_date+"  "+astro);
	}
	
	
}  */
//添加星座
function addAstro(){
	var born_date=$("#born_date").val();
	
	$("#born_date_str").val(born_date);
		var array=born_date.split("-"); //字符分割 
		var m=parseInt(array[1]);
		var d=parseInt(array[2]);
		//水瓶座1.20-2.18
		if(m==1){
            if(d>=20&&d<=31){
            	$("#born_date").val(born_date+"  "+"水瓶座");
            }
        }
        if(m==2){
            if(d>=1&&d<=18){
            	$("#born_date").val(born_date+"  "+"水瓶座");
            }
        }
        //双鱼座2.19-3.20
        if(m==2){
            if(d>=19&&d<=31){
            	$("#born_date").val(born_date+"  "+"双鱼座");
            }
        }
        if(m==3){
            if(d>=1&&d<=20){
            	$("#born_date").val(born_date+"  "+"双鱼座");
            }
        }
 
        // 白羊座3.21-4.19
        if(m==3){
            if(d>=21&&d<=31){
            	$("#born_date").val(born_date+"  "+"白羊座");
            }
        }
        if(m==4){
            if(d>=1&&d<=19){
            	$("#born_date").val(born_date+"  "+"白羊座");
            }
        }
 
        //金牛座4.20-5.20
        if(m==4){
            if(d>=20&&d<=31){
            	$("#born_date").val(born_date+"  "+"金牛座");
            }
        }
        if(m==5){
            if(d>=1&&d<=20){
            	$("#born_date").val(born_date+"  "+"金牛座");
            }
        }
 
        //双子座5.21-6.21
        if(m==5){
            if(d>=21&&d<=31){
            	$("#born_date").val(born_date+"  "+"双子座");
            }
        }
        if(m==6){
            if(d>=1&&d<=21){
            	$("#born_date").val(born_date+"  "+"双子座");
            }
        }
 
        //巨蟹座6.22-7.22
        if(m==6){
            if(d>=22&&d<=31){
            	$("#born_date").val(born_date+"  "+"巨蟹座");
            }
        }
        if(m==7){
            if(d>=1&&d<=22){
            	$("#born_date").val(born_date+"  "+"巨蟹座");
            }
        }
 
        //狮子座7.23-8.22
        if(m==7){
            if(d>=23&&d<=31){
            	$("#born_date").val(born_date+"  "+"狮子座");
            }
        }
        if(m==8){
            if(d>=1&&d<=22){
            	$("#born_date").val(born_date+"  "+"狮子座");
            }
        }
 
        //处女座8.23-9.22
        if(m==8){
            if(d>=23&&d<=31){
            	$("#born_date").val(born_date+"  "+"处女座");
            }
        }
        if(m==9){
            if(d>=1&&d<=22){
            	$("#born_date").val(born_date+"  "+"处女座");
            }
        }
 
        //天枰座9.23-10.23
        if(m==9){
            if(d>=23&&d<=31){
            	$("#born_date").val(born_date+"  "+"天枰座");
            }
        }
        if(m==10){
            if(d>=1&&d<=23){
            	$("#born_date").val(born_date+"  "+"天枰座");
            }
        }
 
        //天蝎座10.24-11.22
        if(m==10){
            if(d>=24&&d<=31){
            	$("#born_date").val(born_date+"  "+"天蝎座");
            }
        }
        if(m==11){
            if(d>=1&&d<=22){
            	$("#born_date").val(born_date+"  "+"天蝎座");
            }
        }
 
        //射手座11.23-12.21
        if(m==11){
            if(d>=23&&d<=31){
            	$("#born_date").val(born_date+"  "+"射手座");
            }
        }
        if(m==12){
            if(d>=1&&d<=21){
            	$("#born_date").val(born_date+"  "+"射手座");
            }
        }
 
        //摩羯座12.22-1.19
        if(m==12){
            if(d>=22&&d<=31){
            	$("#born_date").val(born_date+"  "+"摩羯座");
            }
        }
        if(m==1){
            if(d>=1&&d<=19){
            	$("#born_date").val(born_date+"  "+"摩羯座");
            }
        }


} 
</script>
</html>